<?php
require_once("../globals.php");

// this allows us to keep our viewtype between screens -- JRM
$viewtype = 'month';
if (isset($_SESSION['viewtype'])) { $viewtype = $_SESSION['viewtype']; }

// this allows us to keep our selected providers between screens -- JRM
$pcuStr = "pc_username=".$_SESSION['authUser'];
if (isset($_SESSION['pc_username'])) {
    $pcuStr = "";
    if (count($_SESSION['pc_username']) > 1) {
        // loop over the array of values in pc_username to build
        // a list of pc_username HTTP vars
        foreach ($_SESSION['pc_username'] as $pcu) {
            $pcuStr .= "&pc_username[]=".$pcu;
        }
    }
    else {
        // two possibilities here
        // 1) pc_username is an array with a single element
        // 2) pc_username is just a string, not an array
        if (is_string($_SESSION['pc_username'])) {
            $pcuStr .= "&pc_username[]=".$_SESSION['pc_username'];
        }
        else {
            $pcuStr .= "&pc_username[]=".$_SESSION['pc_username'][0];
        }
    }
}

// different frame source page depending on session vars
if ($_SESSION['userauthorized'] && $GLOBALS['docs_see_entire_calendar']) {
    $framesrc = "calendar/index.php?module=PostCalendar&viewtype=".$viewtype."&func=view";
}
else if ($_SESSION['userauthorized']) {
    $framesrc = "calendar/index.php?module=PostCalendar&viewtype=".$viewtype."&func=view&".$pcuStr;
}
else {
    $framesrc = "calendar/index.php?module=PostCalendar&func=view&viewtype=".$viewtype;
}
?>

<script language='JavaScript'>

$( document ).ready(function() {
	$.get("<?php echo $framesrc;?>",function(data){
		$("#info").html(data);
	});	
});

<?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>

</script> 
